﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WCS.Infrastructure.Dto.Common;

namespace WCS.Infrastructure.Dto.Request.Payment
{
    /// <summary>
    /// 分成协议表
    /// </summary>
    public class DividedAgreementRequestDto:BaseRequestDto
    {

        /// <summary>
        /// 分账协议ID
        /// </summary>
        [Key]
        [StringLength(32)]
        public string? Id { get; set; } = null!;

        /// <summary>
        /// 分账协议编号
        /// </summary>
        [StringLength(32)]
        public string? AgreementCode { get; set; } = null!;

        /// <summary>
        /// 分账协议名称
        /// </summary>
        [StringLength(255)]
        public string? AgreementName { get; set; }

        /// <summary>
        /// 父级协议ID
        /// </summary>
        [StringLength(32)]
        public string? ParentAgreementId { get; set; }

        /// <summary>
        /// 生效时间
        /// </summary>
        [Column(TypeName = "timestamp(6) without time zone")]
        public DateTime? StartTime { get; set; }

        /// <summary>
        /// 失效时间（为空为长期有效）
        /// </summary>
        [Column(TypeName = "timestamp(6) without time zone")]
        public DateTime? EndTime { get; set; }

        /// <summary>
        /// 扩展属性
        /// </summary>
        public string? ExtraProperties { get; set; }

        /// <summary>
        /// 并发标记
        /// </summary>
        [StringLength(40)]
        public string? ConcurrencyStamp { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [Column(TypeName = "timestamp(6) without time zone")]
        public DateTime? CreationTime { get; set; }

        /// <summary>
        /// 创建人ID
        /// </summary>
        [StringLength(32)]
        public string? CreatorId { get; set; }

        /// <summary>
        /// 最后修改时间
        /// </summary>
        [Column(TypeName = "timestamp(6) without time zone")]
        public DateTime? LastModificationTime { get; set; }

        /// <summary>
        /// 最后修改人ID
        /// </summary>
        [StringLength(32)]
        public string? LastModifierId { get; set; }

        /// <summary>
        /// 是否删除
        /// </summary>
        public bool? IsDeleted { get; set; }

        /// <summary>
        /// 删除者ID
        /// </summary>
        [StringLength(32)]
        public string? DeleterId { get; set; }

        /// <summary>
        /// 删除时间
        /// </summary>
        [Column(TypeName = "timestamp(6) without time zone")]
        public DateTime? DeletionTime { get; set; }

        /// <summary>
        /// 启用状态(0=禁用，1=启用，用户设置)
        /// </summary>
        public int? EnableStatus { get; set; } = 1;

        /// <summary>
        /// 激活状态(0=未激活，1=已激活，系统判断)
        /// </summary>
        public int? ActivationStatus { get; set; }

        /// <summary>
        /// 分账周期
        /// </summary>
        public int? DividedCycle { get; set; }

        /// <summary>
        /// 所属商户ID
        /// </summary>
        [StringLength(32)]
        public string? MerchantId { get; set; }


        ////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// 收款码Id集合
        /// </summary>
        public List<string> CodeIds { get; set; } = new List<string>();

        /// <summary>
        /// 收款码名称集合
        /// </summary>
        public List<string> CodeNames { get; set; } = new List<string>();

        /// <summary>
        /// 创建人名称
        /// </summary>
        public string? CreatorName { get; set; }

        /// <summary>
        /// 最后修改人名称
        /// </summary>
        public string? LastModifierName { get; set; }

        /// <summary>
        /// 删除者名称
        /// </summary>
        public string? DeleterName { get; set; }
    }

    /// <summary>
    /// 在分账协议里批量设置收款码 请求对象
    /// </summary>
    public class SetDividedAgreementPaymentCodesRequestDto
    {
        /// <summary>
        /// 分账协议ID（必填）
        /// </summary>
        [Required]
        [StringLength(32)]
        public string DividedAgreementId { get; set; }

        /// <summary>
        /// 目标收款码ID集合（为空表示清空该协议下所有收款码）
        /// </summary>
        public List<string> PaymentCodeIds { get; set; } = new List<string>();

        /// <summary>
        /// 商户ID（可选；将与分账协议及收款码所属商户进行一致性校验）
        /// </summary>
        [StringLength(32)]
        public string? MerchantId { get; set; }
    }

    /// <summary>
    /// 批量给收款码设置分账协议 请求对象
    /// </summary>
    public class SetPaymentCodesDividedAgreementRequestDto
    {
        /// <summary>
        /// 收款码ID集合
        /// </summary>
        [Required]
        public List<string> PaymentCodeIds { get; set; } = new List<string>();

        /// <summary>
        /// 目标分账协议ID（为空表示解绑）
        /// </summary>
        [StringLength(32)]
        public string? DividedAgreementId { get; set; }

        /// <summary>
        /// 商户ID（可选；为空时将根据收款码反推并要求一致）
        /// </summary>
        [StringLength(32)]
        public string? MerchantId { get; set; }
    }
}
